Skip to content

Make addLocalRpaths an enum to support different build configurations#10053

Open
rbenegal wants to merge 3 commits into
swiftlang:mainfrom
rbenegal:rbenegal/avoid-rpaths-for-release-configs
Open

Make addLocalRpaths an enum to support different build configurations#10053
rbenegal wants to merge 3 commits into
swiftlang:mainfrom
rbenegal:rbenegal/avoid-rpaths-for-release-configs

Conversation

@rbenegal
Copy link
Copy Markdown

@rbenegal rbenegal commented May 13, 2026

Allow for addLocalRpaths to be called with one of: .never, .debugOnly or .always to allow for selectively adding rpaths based on build requirements.

Motivation:

In the release configuration adding local rpaths can cause linker warnings and issues with location, relocation, performance and security. Instead of always adding rpaths, the .debugOnly option can be used to ensure that release configs do not get an rpath.

Modifications:

addLocalRpaths was converted to an enum to allow for .never, .debugOnly or .always options. Tests and comments were updated accordingly.

Result:

Users of PIFBuilder can now turn off rpaths for the release configuration but keep rpaths on for debug configurations to assist with debugging. The previous functionality of turning off rpaths completely is still available with the .never option.

Related: rdar://173020084

rpaths should only be used in the debug configuration to assist with
debugging. In the release configuration these can cause linker warnings
and issues with location, relocation, performance and security.
Comment thread Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Modules.swift
@pmattos
Copy link
Copy Markdown
Contributor

pmattos commented May 13, 2026

@swift-ci test

Allow for PIFBuilder to be called with addLocalRpathsInReleaseConfiguration=false
so that rpaths can be turned off only for the release configuration but kept on
for debug configurations.
@rbenegal rbenegal changed the title Don't add rpaths to the release configuration Add addLocalRpathsInReleaseConfiguration parameter to PIFBuilder May 15, 2026
Comment thread Sources/SwiftBuildSupport/PackagePIFBuilder.swift Outdated
addLocalRpaths can now be set to one of: .never, .debugOnly or .always
to allow for selectively adding rpaths based on build requirements.
@rbenegal rbenegal changed the title Add addLocalRpathsInReleaseConfiguration parameter to PIFBuilder Make addLocalRpaths an enum to support different build configurations May 15, 2026
@rbenegal
Copy link
Copy Markdown
Author

@swift-ci test

Copy link
Copy Markdown
Contributor

@pmattos pmattos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment thread Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Modules.swift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants